import { request } from '@umijs/max';

// 查询交易记录（支持多条件复合查询）
export async function getTransactionList(params?: {
  page?: number;
  size?: number;
  cardId?: string;
  tradeType?: '存入' | '支取';
  startDate?: string;
  endDate?: string;
  minAmount?: number;
  maxAmount?: number;
}, options?: { [key: string]: any }) {
  return request('/api/admin/transactions', {
    method: 'GET',
    params: {
      page: params?.page,
      size: params?.size,
      cardId: params?.cardId,
      tradeType: params?.tradeType,
      startDate: params?.startDate,
      endDate: params?.endDate,
      minAmount: params?.minAmount,
      maxAmount: params?.maxAmount,
    },
    ...(options || {}),
  });
}

// 删除交易记录
export async function deleteTransaction(tradeId: number, options?: { [key: string]: any }) {
  return request('/api/admin/transactions', {
    method: 'DELETE',
    params: { trade_id: tradeId },
    ...(options || {}),
  });
}

// 查询客户自己的交易记录（支持多条件复合查询）
export async function getCustomerTransactionList(params?: {
  page?: number;
  size?: number;
  cardId?: string;
  tradeType?: string;
  startDate?: string;
  endDate?: string;
  minAmount?: number;
  maxAmount?: number;
  remark?: string;
}, options?: { [key: string]: any }) {
  return request('/api/customers/cards/transactions', {
    method: 'GET',
    params: {
      page: params?.page,
      size: params?.size,
      cardId: params?.cardId,
      tradeType: params?.tradeType,
      startDate: params?.startDate,
      endDate: params?.endDate,
      minAmount: params?.minAmount,
      maxAmount: params?.maxAmount,
    },
    ...(options || {}),
  });
} 